
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';

class PhotoPreviewPage extends StatelessWidget{
  String imgUrl;

  PhotoPreviewPage(this.imgUrl,{Key? key}) : super(key: key);


  @override
  Widget build(BuildContext context) {

    return Container(
      height: double.infinity,
      width: double.infinity,
      color: Colors.black,
      alignment: Alignment.center,
      child: GestureDetector(
        child: _createImageProvider(),
        onTap: ()=> Navigator.maybePop(context),
      ),
    );
  }

  Widget _createImageProvider(){
    if(imgUrl.isEmpty) {
      return const SizedBox();
    }else {
      return PhotoView(imageProvider: CachedNetworkImageProvider(imgUrl));
    }
  }
}

